_require local "../../../../basis.smi"
_require local "../../../../smlformat-lib.smi"
_require local "../../../libs/env/main/SEnv.smi"
_require local "../../../libs/ids/main/LocalID.smi"
_require local "../../../data/symbols/main/RecordLabel.smi"
_require local "../../debug/main/Bug.smi"
_require local "./ReifyTerm.smi"
_require "./ReifiedTy.ppg.smi"
_require "./ReifiedTerm.ppg.smi"
_require "./PartialDynamic.smi"
_require local "./NaturalJoin.smi"
_require local "./ReifiedTermToML.smi"
_require local "./RecordUtils.smi"
_require local "../../../../smlnj-lib/JSON/json.smi"
_require local "../../../../smlnj-lib/JSON/json-parser.smi"
_require "../../../data/control/main/PrintControl.smi"

structure Dynamic = 
struct
  exception RuntimeTypeError = PartialDynamic.RuntimeTypeError
  exception Format
  exception JSONError of string
  type 'a dyn = 'a ReifiedTerm.dyn
  type void = ReifiedTy.void
  type dynamic = void dyn
  datatype term = datatype ReifiedTerm.reifiedTerm
  datatype ty = datatype ReifiedTy.reifiedTy

  val dynamicToString : dynamic -> string
  val dynamicToTerm : dynamic -> term
  val dynamicToTy : dynamic -> ty
  val dynamicToTyString : dynamic -> string
  val termToDynamic : term -> dynamic
  val termToString : term -> string
  val termToTy : term -> ty
  val tyToString : ty -> string

  val null : dynamic
  val void : dynamic
  val nullWithTy : ty -> dynamic
  val voidWithTy : ty -> dynamic
  val Record : (string * term) list -> term
  val RecordTermToKeyListValueList : term -> (string list * string list)
  val RecordTermToSQLValueList  : term -> string list
  val RecordTy : (string * ty) list -> ty
  val dynamic : ['a#reify.'a -> dynamic]
  val view : ['a#reify.'a dyn -> 'a]

  val fromJson : string -> dynamic
  val fromJsonFile : string -> dynamic
  val toJson : 'a dyn -> string

  val valueToJson : ['a#reify. 'a -> string]

  val printMaxDepth = PrintControl.printMaxDepth
  val printWidth = PrintControl.printWidth
  val pp : ['a#reify. 'a -> unit]
  val debugPrint : ['a#reify. 'a -> unit]
  val format : ['a#reify. 'a -> string]
  val tagOf : ['a#reify. 'a -> string]
  val tagAndValue : ['a#reify. 'a -> string * string]
  val greaterEq : 'a dyn * 'b dyn -> bool
  val ## : string -> 'a dyn -> dynamic
  val ### : ['a#reify#{}, 'b#reify. string -> 'a -> 'b]
  val Hd : 'a dyn -> dynamic
  val Tl : 'a dyn -> dynamic
  val Nil : dynamic
  val Cons : 'a dyn * 'b dyn  -> dynamic
  val join : dynamic * dynamic -> dynamic
  val extend : dynamic * dynamic -> dynamic
  val override : dynamic * dynamic -> dynamic
  val project : ['a#reify#{}, 'b#reify#{}. 'a -> 'b]
  val nest : ['a#reify, 'b#reify. 'a -> 'b]
end

